#include<unistd.h>
#include<signal.h>
#include<stdio.h>
#include<stdlib.h>
#include<sys/param.h>
#include<sys/types.h>
#include<sys/stat.h>
#include<time.h>
#include <string.h>

#define D_UPDATE_PATH "/agvwork"

int main()
{	

	char szExecCmd[1024]={0};
	char szCurrentPath[2048] = D_UPDATE_PATH;
	int deskPathLength = strlen(szCurrentPath);
	if(deskPathLength<=0)
	{
		return -1;
	}
	szCurrentPath[deskPathLength]=0;

	//unzip
	sprintf(szExecCmd,"unzip -qo %s/armPendentHmiPackage.zip -d %s",szCurrentPath,szCurrentPath);
	system(szExecCmd);
	sprintf(szExecCmd,"rm %s/armPendentHmiPackage.zip",szCurrentPath);
	system(szExecCmd);
	sprintf(szExecCmd,"chmod -R 777 %s/agvwork",szCurrentPath);
	system(szExecCmd);

	sprintf(szExecCmd,"cp -rf %s/agvwork/* /agvwork/",szCurrentPath);
	system(szExecCmd);
	//删除解压缩后的文件夹
	sprintf(szExecCmd,"rm -rf %s/agvwork",szCurrentPath);
	system(szExecCmd);	
    system("sh /agvwork/AgvHmi/baseBag/hmiProject/bin/arm/hmi.sh");

    while(1)
    {
        sleep(11);
    }

    return 0;
}
